package cn.xmkeshe.back.impl;

import cn.xmkeshe.back.IRecordServiceBack;
import cn.xmkeshe.dao.IRecordDao;
import cn.xmkeshe.model.Record;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class IRecordServiceBackImpl implements IRecordServiceBack {

  @Resource
  private IRecordDao iStatDao;


  @Override
  @Transactional(readOnly = true)
  public List<Record> find() {
    return iStatDao.find();
  }

  @Override
  @Transactional(readOnly = true)
  public List<Record> findStatus() {
    List<Record> status = iStatDao.findStatus();
    for (int i=0;i<status.size();i++){
      if(status.get(i).getName().equals("1")){
        status.get(i).setName("未处理");
      }else if (status.get(i).getName().equals("2")){
        status.get(i).setName("运输中");
      }else{
        status.get(i).setName("已完结");
      }
    }
    return status;
  }

  @Override
  @Transactional(readOnly = true)
  public List<Record> aaccountStatus() {
    List<Record> status = iStatDao.aaccountStatus();
    for (int i=0;i<status.size();i++){
      if(status.get(i).getName().equals("0")){
        status.get(i).setName("未对账");
      }else{
        status.get(i).setName("已对账");
      }
    }
    return status;
  }

  @Override
  @Transactional(readOnly = true)
  public List<Record> caccountStatus() {
    List<Record> status = iStatDao.caccountStatus();
    for (int i=0;i<status.size();i++){
      if(status.get(i).getName().equals("0")){
        status.get(i).setName("未对账");
      }else{
        status.get(i).setName("已对账");
      }
    }
    return status;
  }
}
